package com.woniuxy.controller;

import com.woniuxy.entity.Menu;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName RbacMenuController
 * @Description TODO
 * @Author LI.hh
 * @Date 2022/9/10 15:21
 * @Version 1.0
 */
@RequestMapping("/rbacMenu")
@RestController
@CrossOrigin
public class RbacMenuController {
    @Autowired
    RbacMenuService rbacMenuService;

    @GetMapping("/{id}")
    public ResponseEntity findAll(@PathVariable int id){
        return rbacMenuService.findAll(id);
    }
    @RequestMapping("/findAllId")
    public ResponseEntity findAllId(int id){
        return rbacMenuService.findAllId(id);
    }

    @GetMapping("/")
    public ResponseEntity findAllMenu(){
        return rbacMenuService.findAllMenu();
    }

    @PostMapping("/")
    public ResponseEntity editOne(@RequestBody Menu rbacMenu){
        return rbacMenuService.editOne(rbacMenu);
    }

    @PutMapping("/{id}")
    public ResponseEntity deleteMenu(@PathVariable int id){
        return rbacMenuService.deleteMenu(id);
    }

    @PutMapping("/insertMenu/{id}/{roleId}")
    public ResponseEntity insertMenu(@PathVariable int id,@PathVariable int roleId){
        System.out.println(roleId+"添加了id为"+id+"的菜单");
        return rbacMenuService.insertMenu(id,roleId);
    }

    @PostMapping("/addOne")
    public ResponseEntity addOne(@RequestBody Menu rbacMenu){
        return rbacMenuService.addOne(rbacMenu);
    }

    @PutMapping("/{id}/{fid}")
    public ResponseEntity updateMenu(@PathVariable int id,@PathVariable Integer fid){
        return rbacMenuService.updateMenu(id,fid);
    }
    @PutMapping("/deleteOne/{id}")
    public ResponseEntity deleteOne(@PathVariable int id){
        return rbacMenuService.deleteOne(id);
    }
}
